package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */


    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    Page<DishVO> queryByPage(DishPageQueryDTO dishPageQueryDTO);

    /**
     根据传入的id 获取对应的菜品id
     */
    @Select("select * from dish where id = #{id}")
    Dish getId(Long id);

    void delete(List<Long> ids);

    List<Long> getmeal_dish_id(List<Long> ids);

    @Select("select * from dish where id = #{id}")
    DishVO getDishData(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    @Update("update dish set status = #{status} where id = #{id}")
    void startOrstopDish(Long id,Integer status);














    List<Dish> getstatus(List<Long> ids);

    List<SetmealDish> setmeal_dish_id(List<Long> ids);


    List<Dish> list(Dish dish);

    Dish queryByID(Long categoryId);

    @Select("select status from dish where id = #{id}")
    Integer getstatusByid(Long id);


    @Select("select setmeal_id from setmeal_dish where dish_id = #{id}")
    List<Long> getSetmealId(Long id);

    @Update("update dish set status = #{code} where id = #{id}")
    void start(Integer code , Long id);

    @Update("update dish set status = #{code} where id = #{id}")
    void stop(Integer code,Long id);

    @Update("update dish set status = #{status} where id = #{id}")
    void updateStatus(int status, Long id);

    @Select("select dish.status from dish where id = #{id}")
    Integer lookStatus();


}
